{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-11-03T04:56:52.154431Z",
     "start_time": "2019-11-03T04:56:50.822041Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <a href=\"https://bokeh.pydata.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
       "        <span id=\"1001\">Loading BokehJS ...</span>\n",
       "    </div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "\n",
       "(function(root) {\n",
       "  function now() {\n",
       "    return new Date();\n",
       "  }\n",
       "\n",
       "  var force = true;\n",
       "\n",
       "  if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
       "    root._bokeh_onload_callbacks = [];\n",
       "    root._bokeh_is_loading = undefined;\n",
       "  }\n",
       "\n",
       "  var JS_MIME_TYPE = 'application/javascript';\n",
       "  var HTML_MIME_TYPE = 'text/html';\n",
       "  var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n",
       "  var CLASS_NAME = 'output_bokeh rendered_html';\n",
       "\n",
       "  /**\n",
       "   * Render data to the DOM node\n",
       "   */\n",
       "  function render(props, node) {\n",
       "    var script = document.createElement(\"script\");\n",
       "    node.appendChild(script);\n",
       "  }\n",
       "\n",
       "  /**\n",
       "   * Handle when an output is cleared or removed\n",
       "   */\n",
       "  function handleClearOutput(event, handle) {\n",
       "    var cell = handle.cell;\n",
       "\n",
       "    var id = cell.output_area._bokeh_element_id;\n",
       "    var server_id = cell.output_area._bokeh_server_id;\n",
       "    // Clean up Bokeh references\n",
       "    if (id != null && id in Bokeh.index) {\n",
       "      Bokeh.index[id].model.document.clear();\n",
       "      delete Bokeh.index[id];\n",
       "    }\n",
       "\n",
       "    if (server_id !== undefined) {\n",
       "      // Clean up Bokeh references\n",
       "      var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n",
       "      cell.notebook.kernel.execute(cmd, {\n",
       "        iopub: {\n",
       "          output: function(msg) {\n",
       "            var id = msg.content.text.trim();\n",
       "            if (id in Bokeh.index) {\n",
       "              Bokeh.index[id].model.document.clear();\n",
       "              delete Bokeh.index[id];\n",
       "            }\n",
       "          }\n",
       "        }\n",
       "      });\n",
       "      // Destroy server and session\n",
       "      var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n",
       "      cell.notebook.kernel.execute(cmd);\n",
       "    }\n",
       "  }\n",
       "\n",
       "  /**\n",
       "   * Handle when a new output is added\n",
       "   */\n",
       "  function handleAddOutput(event, handle) {\n",
       "    var output_area = handle.output_area;\n",
       "    var output = handle.output;\n",
       "\n",
       "    // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n",
       "    if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n",
       "      return\n",
       "    }\n",
       "\n",
       "    var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n",
       "\n",
       "    if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n",
       "      toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n",
       "      // store reference to embed id on output_area\n",
       "      output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n",
       "    }\n",
       "    if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n",
       "      var bk_div = document.createElement(\"div\");\n",
       "      bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
       "      var script_attrs = bk_div.children[0].attributes;\n",
       "      for (var i = 0; i < script_attrs.length; i++) {\n",
       "        toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n",
       "      }\n",
       "      // store reference to server id on output_area\n",
       "      output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function register_renderer(events, OutputArea) {\n",
       "\n",
       "    function append_mime(data, metadata, element) {\n",
       "      // create a DOM node to render to\n",
       "      var toinsert = this.create_output_subarea(\n",
       "        metadata,\n",
       "        CLASS_NAME,\n",
       "        EXEC_MIME_TYPE\n",
       "      );\n",
       "      this.keyboard_manager.register_events(toinsert);\n",
       "      // Render to node\n",
       "      var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
       "      render(props, toinsert[toinsert.length - 1]);\n",
       "      element.append(toinsert);\n",
       "      return toinsert\n",
       "    }\n",
       "\n",
       "    /* Handle when an output is cleared or removed */\n",
       "    events.on('clear_output.CodeCell', handleClearOutput);\n",
       "    events.on('delete.Cell', handleClearOutput);\n",
       "\n",
       "    /* Handle when a new output is added */\n",
       "    events.on('output_added.OutputArea', handleAddOutput);\n",
       "\n",
       "    /**\n",
       "     * Register the mime type and append_mime function with output_area\n",
       "     */\n",
       "    OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n",
       "      /* Is output safe? */\n",
       "      safe: true,\n",
       "      /* Index of renderer in `output_area.display_order` */\n",
       "      index: 0\n",
       "    });\n",
       "  }\n",
       "\n",
       "  // register the mime type if in Jupyter Notebook environment and previously unregistered\n",
       "  if (root.Jupyter !== undefined) {\n",
       "    var events = require('base/js/events');\n",
       "    var OutputArea = require('notebook/js/outputarea').OutputArea;\n",
       "\n",
       "    if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n",
       "      register_renderer(events, OutputArea);\n",
       "    }\n",
       "  }\n",
       "\n",
       "  \n",
       "  if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "    root._bokeh_timeout = Date.now() + 5000;\n",
       "    root._bokeh_failed_load = false;\n",
       "  }\n",
       "\n",
       "  var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "     \"<div style='background-color: #fdd'>\\n\"+\n",
       "     \"<p>\\n\"+\n",
       "     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "     \"</p>\\n\"+\n",
       "     \"<ul>\\n\"+\n",
       "     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "     \"</ul>\\n\"+\n",
       "     \"<code>\\n\"+\n",
       "     \"from bokeh.resources import INLINE\\n\"+\n",
       "     \"output_notebook(resources=INLINE)\\n\"+\n",
       "     \"</code>\\n\"+\n",
       "     \"</div>\"}};\n",
       "\n",
       "  function display_loaded() {\n",
       "    var el = document.getElementById(\"1001\");\n",
       "    if (el != null) {\n",
       "      el.textContent = \"BokehJS is loading...\";\n",
       "    }\n",
       "    if (root.Bokeh !== undefined) {\n",
       "      if (el != null) {\n",
       "        el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n",
       "      }\n",
       "    } else if (Date.now() < root._bokeh_timeout) {\n",
       "      setTimeout(display_loaded, 100)\n",
       "    }\n",
       "  }\n",
       "\n",
       "\n",
       "  function run_callbacks() {\n",
       "    try {\n",
       "      root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
       "    }\n",
       "    finally {\n",
       "      delete root._bokeh_onload_callbacks\n",
       "    }\n",
       "    console.info(\"Bokeh: all callbacks have finished\");\n",
       "  }\n",
       "\n",
       "  function load_libs(js_urls, callback) {\n",
       "    root._bokeh_onload_callbacks.push(callback);\n",
       "    if (root._bokeh_is_loading > 0) {\n",
       "      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "      return null;\n",
       "    }\n",
       "    if (js_urls == null || js_urls.length === 0) {\n",
       "      run_callbacks();\n",
       "      return null;\n",
       "    }\n",
       "    console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "    root._bokeh_is_loading = js_urls.length;\n",
       "    for (var i = 0; i < js_urls.length; i++) {\n",
       "      var url = js_urls[i];\n",
       "      var s = document.createElement('script');\n",
       "      s.src = url;\n",
       "      s.async = false;\n",
       "      s.onreadystatechange = s.onload = function() {\n",
       "        root._bokeh_is_loading--;\n",
       "        if (root._bokeh_is_loading === 0) {\n",
       "          console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
       "          run_callbacks()\n",
       "        }\n",
       "      };\n",
       "      s.onerror = function() {\n",
       "        console.warn(\"failed to load library \" + url);\n",
       "      };\n",
       "      console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "      document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "    }\n",
       "  };var element = document.getElementById(\"1001\");\n",
       "  if (element == null) {\n",
       "    console.log(\"Bokeh: ERROR: autoload.js configured with elementid '1001' but no matching script tag was found. \")\n",
       "    return false;\n",
       "  }\n",
       "\n",
       "  var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.0.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.0.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.0.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-1.0.0.min.js\"];\n",
       "\n",
       "  var inline_js = [\n",
       "    function(Bokeh) {\n",
       "      Bokeh.set_log_level(\"info\");\n",
       "    },\n",
       "    \n",
       "    function(Bokeh) {\n",
       "      \n",
       "    },\n",
       "    function(Bokeh) {\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-1.0.0.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.0.min.css\");\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.0.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.0.min.css\");\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.0.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.0.min.css\");\n",
       "    }\n",
       "  ];\n",
       "\n",
       "  function run_inline_js() {\n",
       "    \n",
       "    if ((root.Bokeh !== undefined) || (force === true)) {\n",
       "      for (var i = 0; i < inline_js.length; i++) {\n",
       "        inline_js[i].call(root, root.Bokeh);\n",
       "      }if (force === true) {\n",
       "        display_loaded();\n",
       "      }} else if (Date.now() < root._bokeh_timeout) {\n",
       "      setTimeout(run_inline_js, 100);\n",
       "    } else if (!root._bokeh_failed_load) {\n",
       "      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "      root._bokeh_failed_load = true;\n",
       "    } else if (force !== true) {\n",
       "      var cell = $(document.getElementById(\"1001\")).parents('.cell').data().cell;\n",
       "      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "    }\n",
       "\n",
       "  }\n",
       "\n",
       "  if (root._bokeh_is_loading === 0) {\n",
       "    console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "    run_inline_js();\n",
       "  } else {\n",
       "    load_libs(js_urls, function() {\n",
       "      console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "      run_inline_js();\n",
       "    });\n",
       "  }\n",
       "}(window));"
      ],
      "application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n  function now() {\n    return new Date();\n  }\n\n  var force = true;\n\n  if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n    root._bokeh_onload_callbacks = [];\n    root._bokeh_is_loading = undefined;\n  }\n\n  \n\n  \n  if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n    root._bokeh_timeout = Date.now() + 5000;\n    root._bokeh_failed_load = false;\n  }\n\n  var NB_LOAD_WARNING = {'data': {'text/html':\n     \"<div style='background-color: #fdd'>\\n\"+\n     \"<p>\\n\"+\n     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n     \"</p>\\n\"+\n     \"<ul>\\n\"+\n     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n     \"</ul>\\n\"+\n     \"<code>\\n\"+\n     \"from bokeh.resources import INLINE\\n\"+\n     \"output_notebook(resources=INLINE)\\n\"+\n     \"</code>\\n\"+\n     \"</div>\"}};\n\n  function display_loaded() {\n    var el = document.getElementById(\"1001\");\n    if (el != null) {\n      el.textContent = \"BokehJS is loading...\";\n    }\n    if (root.Bokeh !== undefined) {\n      if (el != null) {\n        el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n      }\n    } else if (Date.now() < root._bokeh_timeout) {\n      setTimeout(display_loaded, 100)\n    }\n  }\n\n\n  function run_callbacks() {\n    try {\n      root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n    }\n    finally {\n      delete root._bokeh_onload_callbacks\n    }\n    console.info(\"Bokeh: all callbacks have finished\");\n  }\n\n  function load_libs(js_urls, callback) {\n    root._bokeh_onload_callbacks.push(callback);\n    if (root._bokeh_is_loading > 0) {\n      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n      return null;\n    }\n    if (js_urls == null || js_urls.length === 0) {\n      run_callbacks();\n      return null;\n    }\n    console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n    root._bokeh_is_loading = js_urls.length;\n    for (var i = 0; i < js_urls.length; i++) {\n      var url = js_urls[i];\n      var s = document.createElement('script');\n      s.src = url;\n      s.async = false;\n      s.onreadystatechange = s.onload = function() {\n        root._bokeh_is_loading--;\n        if (root._bokeh_is_loading === 0) {\n          console.log(\"Bokeh: all BokehJS libraries loaded\");\n          run_callbacks()\n        }\n      };\n      s.onerror = function() {\n        console.warn(\"failed to load library \" + url);\n      };\n      console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n      document.getElementsByTagName(\"head\")[0].appendChild(s);\n    }\n  };var element = document.getElementById(\"1001\");\n  if (element == null) {\n    console.log(\"Bokeh: ERROR: autoload.js configured with elementid '1001' but no matching script tag was found. \")\n    return false;\n  }\n\n  var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.0.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.0.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.0.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-1.0.0.min.js\"];\n\n  var inline_js = [\n    function(Bokeh) {\n      Bokeh.set_log_level(\"info\");\n    },\n    \n    function(Bokeh) {\n      \n    },\n    function(Bokeh) {\n      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-1.0.0.min.css\");\n      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.0.min.css\");\n      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.0.min.css\");\n      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.0.min.css\");\n      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.0.min.css\");\n      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.0.min.css\");\n    }\n  ];\n\n  function run_inline_js() {\n    \n    if ((root.Bokeh !== undefined) || (force === true)) {\n      for (var i = 0; i < inline_js.length; i++) {\n        inline_js[i].call(root, root.Bokeh);\n      }if (force === true) {\n        display_loaded();\n      }} else if (Date.now() < root._bokeh_timeout) {\n      setTimeout(run_inline_js, 100);\n    } else if (!root._bokeh_failed_load) {\n      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n      root._bokeh_failed_load = true;\n    } else if (force !== true) {\n      var cell = $(document.getElementById(\"1001\")).parents('.cell').data().cell;\n      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n    }\n\n  }\n\n  if (root._bokeh_is_loading === 0) {\n    console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n    run_inline_js();\n  } else {\n    load_libs(js_urls, function() {\n      console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n      run_inline_js();\n    });\n  }\n}(window));"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import torch\n",
    "import torch.nn as nn\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "from bokeh.io import show, output_notebook\n",
    "from bokeh.plotting import figure, gridplot\n",
    "from bokeh.models import LinearAxis, Range1d\n",
    "output_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-11-02T15:34:18.036850Z",
     "start_time": "2019-11-02T15:34:18.032937Z"
    }
   },
   "source": [
    "### Data\n",
    "构造`y=3x+5`的数据点`(x,y)`并加入噪声。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-11-03T04:56:52.170355Z",
     "start_time": "2019-11-03T04:56:52.160379Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(20, 1) (20, 1)\n"
     ]
    }
   ],
   "source": [
    "n_data = 20\n",
    "x_train = np.array([np.random.rand(n_data)*10])\n",
    "y_train = 3*x_train+ 5 + np.random.rand(n_data)*3-1.5\n",
    "x_train = x_train.reshape(n_data, -1)\n",
    "y_train = y_train.reshape(n_data, -1)\n",
    "print(x_train.shape, y_train.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-11-03T04:56:52.516573Z",
     "start_time": "2019-11-03T04:56:52.176412Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYMAAAELCAYAAAA7h+qnAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAAD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z4NIklyR5Ba0BpPv6XFPPJAmtPuN9VfXxftfTS1W1uaourqo1tP6/P1RVI/Mvw6r6BvDXSda2m94GfLmPJfXa08CVSc5t/z14GyM0gL7AfcCN7fs3Avee6RsO5B7IVXU0yXuAHbRmE9xZVU/2uaxeugp4F7Anye522wer6vN9rEm982+Bu9r/EPoq8K/7XE/PVNVjSe4BvkRrVt0uhvxq5CSfAa4GViV5BvgQcBtwd5J30wrIXzjjz/EKZEnSoHYTSZKWkWEgSTIMJEmGgSQJw0CShGEgScIwkLqSZE2Sd/6Ar/3ictcjLTfDQOrOGqBjGLRXz1xUVY3icgkaMIaBRlqStyR5Isk5SV7Z3jTlzR0OvQ34J0l2tzdXuSnJ/07y+8AfJjkvyYNJvpRkT5LrFnzGc+2fVyf5woKNae5qL6kg9Z1XIGvkJfkIcA4wQWsRuFs7HHM18O+q6h3txzcBHwH+QVV9e35t/ar6bpJVwJ8Cl1ZVJXmuqs5rv8e9wN+ntbDiHwObqurRxr+kdBoDuTaRtMx+ndbih9+jtYtWtx6oqvlNRwL8RpKfpLXPwjTwGuAbJ7zmz6rqGYD2ulJrAMNAfWcYSHAhcB4wTusM4fkuX7fwuF8EpoB/VFVH2ktsd9qb94UF94/h30GtEI4ZSK1VL/8DcBfwm4sc8yzwqlO8x/m0Nt05kuSngB9d3hKlZvmvEo20JP8KOFpVv5tkDPhikmuq6qETDn0COJrkL2htUP6dE56/C/j9JDuB3cBXGi5dWlYOIEuS7CaSJNlNJB0nyWXAb5/Q/EJV/eN+1CP1it1EkiS7iSRJhoEkCcNAkoRhIEnCMJAkAf8fg3dEt2G+0S4AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure() \n",
    "#画图散点图\n",
    "plt.scatter(x_train,y_train)\n",
    "plt.xlabel('x_train')\n",
    "#x轴名称\n",
    "plt.ylabel('y_train')\n",
    "#y轴名称\n",
    "#显示图片\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Model\n",
    "构造线性回归模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-11-03T04:56:52.525974Z",
     "start_time": "2019-11-03T04:56:52.520822Z"
    }
   },
   "outputs": [],
   "source": [
    "class LinearRegression(nn.Module):\n",
    "    def __init__(self, dim_in, dim_out):\n",
    "        super().__init__()\n",
    "        self.linear = nn.Linear(dim_in, dim_out)\n",
    "    def forward(self, x):\n",
    "        return self.linear(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-11-03T04:56:52.619241Z",
     "start_time": "2019-11-03T04:56:52.527902Z"
    }
   },
   "outputs": [],
   "source": [
    "dim_in = 1\n",
    "dim_out = 1\n",
    "lrate = 0.001\n",
    "epochs = 600\n",
    "\n",
    "model = LinearRegression(dim_in, dim_out).double()\n",
    "criterion = nn.MSELoss()\n",
    "optim = torch.optim.SGD(model.parameters(), lr=lrate)\n",
    "\n",
    "inputs = torch.from_numpy(x_train).double()\n",
    "targets = torch.from_numpy(y_train).double()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "注意：每次反向传播的时候都需要将参数的梯度归零。  \n",
    "`optim.step()`则在每个`Variable`的`grad`都被计算出来后，更新每个`Variable`的数值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-11-03T04:56:53.163728Z",
     "start_time": "2019-11-03T04:56:52.621563Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "  <div class=\"bk-root\" id=\"96abf8e5-1086-49b1-b0d0-3653c588e5e8\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    \n",
       "  var docs_json = {\"46d91368-31c8-4570-8911-3b52a4a7de5d\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1011\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"1016\",\"type\":\"LinearAxis\"}],\"renderers\":[{\"id\":\"1011\",\"type\":\"LinearAxis\"},{\"id\":\"1015\",\"type\":\"Grid\"},{\"id\":\"1016\",\"type\":\"LinearAxis\"},{\"id\":\"1020\",\"type\":\"Grid\"},{\"id\":\"1029\",\"type\":\"BoxAnnotation\"},{\"id\":\"1039\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"1042\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"1027\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"1003\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"1007\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"1005\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"1009\",\"type\":\"LinearScale\"}},\"id\":\"1002\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"1026\",\"type\":\"HelpTool\"},{\"attributes\":{\"source\":{\"id\":\"1036\",\"type\":\"ColumnDataSource\"}},\"id\":\"1040\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1047\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"overlay\":{\"id\":\"1029\",\"type\":\"BoxAnnotation\"}},\"id\":\"1023\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"callback\":null},\"id\":\"1005\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1012\",\"type\":\"BasicTicker\"},{\"attributes\":{\"formatter\":{\"id\":\"1045\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"1002\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1017\",\"type\":\"BasicTicker\"}},\"id\":\"1016\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1022\",\"type\":\"WheelZoomTool\"},{\"attributes\":{},\"id\":\"1048\",\"type\":\"Selection\"},{\"attributes\":{\"line_color\":\"#1f77b4\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1037\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"1009\",\"type\":\"LinearScale\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1021\",\"type\":\"PanTool\"},{\"id\":\"1022\",\"type\":\"WheelZoomTool\"},{\"id\":\"1023\",\"type\":\"BoxZoomTool\"},{\"id\":\"1024\",\"type\":\"SaveTool\"},{\"id\":\"1025\",\"type\":\"ResetTool\"},{\"id\":\"1026\",\"type\":\"HelpTool\"}]},\"id\":\"1027\",\"type\":\"Toolbar\"},{\"attributes\":{\"data_source\":{\"id\":\"1036\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"1037\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1038\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"1040\",\"type\":\"CDSView\"}},\"id\":\"1039\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1038\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"1021\",\"type\":\"PanTool\"},{\"attributes\":{},\"id\":\"1025\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"1007\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"1024\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"1045\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1029\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"plot\":{\"id\":\"1002\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1012\",\"type\":\"BasicTicker\"}},\"id\":\"1015\",\"type\":\"Grid\"},{\"attributes\":{\"callback\":null},\"id\":\"1003\",\"type\":\"DataRange1d\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"1002\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1017\",\"type\":\"BasicTicker\"}},\"id\":\"1020\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1043\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"callback\":null,\"data\":{\"x\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562,563,564,565,566,567,568,569,570,571,572,573,574,575,576,577,578,579,580,581,582,583,584,585,586,587,588,589,590,591,592,593,594,595,596,597,598,599],\"y\":[334.7795143308272,290.5201037920725,252.20752179271253,219.04266063740315,190.33379314407162,165.48214333139134,143.9693960526594,125.34688502914244,109.22623374708523,95.27125398906959,83.19093300445118,72.73336303242974,63.68048654862522,55.843547621889044,49.05915449741767,43.185871272316206,38.10126756653701,33.69936464582627,29.88842472323276,26.58903732438033,23.73246279840584,21.25919842047976,19.117737175048777,17.26349332822829,15.657872376965614,14.267465974269626,13.063355036783193,12.020506497639229,11.117251120966658,10.334831485344704,9.657010707216484,9.069733742298206,8.560834199788186,8.119780553569747,7.737456456416048,7.405970574588439,7.118491976009855,6.8691076382384155,6.652699103881353,6.46483571050219,6.3016821678148,6.159918554240301,6.036671063968367,5.929452059918317,5.836108182114874,5.7547754290280055,5.683840274881164,5.621906011841553,5.567763614996112,5.520366522361604,5.478808803843977,5.442306263755217,5.4101800826893784,5.381842657530045,5.356785344214181,5.3345678475684934,5.314809036892084,5.297178995699946,5.281392139786343,5.267201260052028,5.254392365829654,5.242780221139995,5.232204480766132,5.222526345544626,5.213625667103706,5.2053984416537915,5.197754640551194,5.190616332380963,5.1839160573858525,5.1775954203321914,5.171603872460209,5.165897657110338,5.160438897031602,5.155194804333385,5.150136996600337,5.14524090490471,5.140485261367358,5.135851655577946,5.131324150621485,5.126888950701451,5.122534113426264,5.118249300757377,5.114025563423886,5.109855154306511,5.105731366898216,5.101648395471765,5.097601214037317,5.0935854715651985,5.089597401288126,5.085633742191014,5.0816916710506215,5.077768743607421,5.073862843642501,5.069972138897314,5.066095042916707,5.062230182019344,5.058376366706453,5.054532566912586,5.05069789058202,5.0468715651240155,5.043052921359996,5.039241379627844,5.035436437753451,5.031637660638578,5.027844671247875,5.024057142806989,5.020274792049103,5.016497373368926,5.012724673762275,5.0089565084456495,5.005192717064409,5.001433160410493,4.997677717581214,4.9939262835197935,4.990178766886442,4.986435088215475,4.982695178320085,4.978958976911473,4.975226431403522,4.97149749587811,4.967772130189443,4.964050299188761,4.960331972053199,4.95661712170486,4.9529057243079375,4.949197758833401,4.945493206682204,4.941792051359093,4.938094278190272,4.934399874078995,4.930708827293989,4.927021127286343,4.923336764530964,4.91965573038935,4.915978016990817,4.912303617129665,4.908632524176191,4.904964731999594,4.901300234901341,4.89763902755739,4.893981104968242,4.890326462415656,4.8866750954252245,4.8830269997339535,4.879382171262188,4.875740606089345,4.872102300432861,4.86846725063002,4.864835453122166,4.861206904441108,4.857581601197255,4.853959540069454,4.850340717796108,4.846725131167526,4.843112777019291,4.839503652226535,4.835897753698942,4.832295078376483,4.8286956232256655,4.825099385236312,4.821506361418793,4.817916548801578,4.8143299444291685,4.810746545360283,4.807166348666277,4.803589351429799,4.8000155507436055,4.79644494370956,4.792877527437726,4.789313299045623,4.7857522556575685,4.782194394404086,4.778639712421422,4.775088206851129,4.771539874839657,4.767994713538078,4.764452720101767,4.760913891690177,4.757378225466632,4.7538457185981455,4.75031636825524,4.746790171611852,4.743267125845168,4.739747228135556,4.736230475666458,4.732716865624311,4.7292063951985,4.725699061581268,4.722194861967687,4.718693793555605,4.715195853545616,4.711701039141007,4.708209347547752,4.7047207759744705,4.701235321632399,4.697752981735401,4.694273753499903,4.690797634144925,4.687324620892034,4.683854710965351,4.6803879015915255,4.6769241899997445,4.6734635734217,4.670006049091599,4.666551614246157,4.663100266124567,4.6596520019685395,4.65620681902225,4.652764714532359,4.649325685748003,4.6458897299207935,4.642456844304798,4.639027026156564,4.635600272735082,4.632176581301808,4.628755949120658,4.625338373457978,4.621923851582586,4.618512380765724,4.615103958281089,4.611698581404815,4.608296247415465,4.604896953594045,4.601500697223985,4.598107475591151,4.594717285983834,4.591330125692745,4.587945992011027,4.584564882234229,4.581186793660327,4.577811723589706,4.574439669325171,4.571070628171938,4.567704597437622,4.564341574432249,4.560981556468249,4.55762454086046,4.5542705249261095,4.550919505984828,4.547571481358639,4.544226448371964,4.540884404351612,4.537545346626775,4.534209272529038,4.530876179392375,4.527546064553134,4.524218925350044,4.5208947591242135,4.517573563219134,4.514255334980659,4.5109400717570205,4.507627770898819,4.5043184297590235,4.50101204569296,4.497708616058331,4.494408138215191,4.491110609525959,4.487816027355403,4.484524389070653,4.481235692041191,4.477949933638842,4.474667111237791,4.471387222214562,4.46811026394802,4.464836233819384,4.461565129212201,4.45829694751236,4.455031686108089,4.451769342389947,4.4485099137508275,4.445253397585945,4.44199979129285,4.43874909227142,4.435501297923849,4.432256405654652,4.429014412870668,4.425775316981056,4.422539115397282,4.419305805533132,4.4160753848046905,4.412847850630369,4.4096232004308735,4.4064014316292175,4.403182541650718,4.39996652792299,4.396753387875952,4.393543118941819,4.390335718555088,4.387131184152571,4.383929513173348,4.380730703058798,4.377534751252586,4.374341655200661,4.371151412351255,4.367964020154875,4.364779476064312,4.361597777534633,4.358418922023171,4.355242906989539,4.3520697298956215,4.348899388205561,4.345731879385779,4.342567200904946,4.339405350234009,4.336246324846166,4.333090122216875,4.329936739823853,4.32678617514706,4.323638425668727,4.320493488873305,4.317351362247532,4.3142120432803575,4.311075529462993,4.307941818288887,4.304810907253721,4.301682793855429,4.29855747559417,4.295434949972337,4.2923152144945576,4.28919826666769,4.286084104000819,4.28297272400525,4.279864124194525,4.276758302084393,4.273655255192834,4.270554981040039,4.267457477148416,4.264362741042591,4.261270770249398,4.258181562297883,4.255095114719294,4.252011425047096,4.248930490816948,4.2458523095667156,4.242776878836464,4.23970419616846,4.2366342591071575,4.233567065199205,4.230502611993459,4.22744089704095,4.2243819178949025,4.221325672110725,4.218272157246014,4.215221370860543,4.212173310516276,4.209127973777343,4.20608535821006,4.203045461382912,4.200008280866562,4.196973814233839,4.193942059059739,4.190913012921437,4.187886673398255,4.184863038071694,4.181842104525406,4.178823870345203,4.175808333119064,4.1727954904371085,4.16978533989162,4.166777879077031,4.163773105589923,4.160771017029024,4.157771610995208,4.15477488509149,4.151780836923037,4.148789464097145,4.145800764223252,4.142814734912932,4.139831373779893,4.136850678439979,4.133872646511159,4.130897275613532,4.127924563369322,4.1249545074028795,4.12198710534068,4.119022354811316,4.116060253445508,4.1131007988760775,4.110143988737972,4.107189820668254,4.104238292306091,4.1012894012927585,4.098343145271653,4.095399521888262,4.09245852879018,4.089520163627116,4.0865844240508595,4.083651307715309,4.080720812276465,4.0777929353924085,4.074867674723323,4.0719450279314815,4.0690249926812445,4.0661075666390545,4.063192747473454,4.060280532855046,4.05737092045654,4.054463907952708,4.051559493020406,4.048657673338559,4.045758446588179,4.042861810452338,4.039967762616187,4.037076300766939,4.034187422593876,4.031301125788341,4.028417408043752,4.025536267055574,4.022657700521341,4.019781706140634,4.016908281615104,4.014037424648441,4.011169132946395,4.0083034042167665,4.0054402361694015,4.0025796265161935,3.9997215729710796,3.9968660732500396,3.994013125071093,3.991162726154306,3.9883148742217687,3.9854695669976197,3.9826268022080256,3.979786577581181,3.976948890847315,3.9741137397386908,3.9712811219895814,3.9684510353363,3.9656234775171733,3.962798446272559,3.95997593934482,3.95715595447835,3.9543384894195457,3.951523541916832,3.9487111097206253,3.9459011905833785,3.9430937822595302,3.940288882505533,3.9374864890798484,3.9346865997429403,3.9318892122572655,3.9290943243872887,3.9263019338994725,3.9235120385622664,3.920724636146118,3.9179397244234764,3.91515730116877,3.912377364158415,3.9095999111708224,3.906824939986385,3.904052448387481,3.9012824341584653,3.898514895085673,3.8957498289574226,3.892987233564002,3.890227106697678,3.887469446152693,3.884714249725257,3.8819615152135443,3.879211240417699,3.8764634231398403,3.873718061184043,3.8709751523563405,3.868234694464733,3.865496685319183,3.862761122731596,3.860028004515846,3.857297328487757,3.8545690924651006,3.8518432942676037,3.8491199317169356,3.8463990026367165,3.843680504852513,3.8409644361918263,3.8382507944841087,3.8355395775607484,3.8328307832550634,3.830124409402326,3.8274204538397214,3.824718914406381,3.8220197889433676,3.8193230752936658,3.8166287713021916,3.813936874815785,3.8112473836832144,3.8085602957551643,3.805875608884244,3.8031933209249793,3.800513429733814,3.797835933169112,3.795160829091133,3.7924881153620804,3.7898177898460323,3.787149850409005,3.7844842949189,3.7818211212455366,3.7791603272606387,3.7765019108378177,3.7738458698525994,3.771192202182404,3.768540905706545,3.7658919783062315,3.7632454178645767,3.760601222266562,3.757959389399084,3.755319917150911,3.7526828034127058,3.75004804607701,3.7474156430382544,3.7447855921927484,3.7421578914386813,3.739532538676117,3.7369095318070045,3.7342888687351588,3.731670547366272,3.7290545656079046,3.7264409213694933,3.723829612562336,3.7212206370996057,3.7186139928963238,3.716009677869392,3.7134076899375628,3.710808027021457,3.708210687043543,3.705615667928155,3.7030229676014748,3.7004325839915397,3.6978445150282453,3.6952587586433223,3.692675312770362,3.6900941753448016,3.6875153443039146,3.6849388175868247,3.6823645931344915,3.679792668889725,3.677223042797162,3.6746557128032777,3.6720906768563895,3.669527932906644,3.666967478906014,3.664409312808309,3.661853432569168,3.659299836146053,3.6567485214982476,3.6541994865868688,3.6516527293748453,3.6491082478269328,3.6465660399097017,3.6440261035915453,3.6414884368426663,3.63895303763508,3.6364199039426213,3.6338890337409246,3.6313604250074447,3.6288340757214383,3.6263099838639645,3.6237881474178932,3.6212685643678917,3.618751232700432,3.6162361504037803,3.6137233154680066,3.6112127258849673,3.6087043796483256,3.60619827475353,3.60369440919782,3.6011927809802247,3.5986933881015624,3.5961962285644433,3.593701300373253,3.5912086015341638,3.588718130055132,3.58622988394589,3.5837438612179504,3.5812600598846047,3.578778477960918,3.5762991134637274,3.5738219644116436,3.5713470288250475,3.5688743047260894,3.566403790138687,3.56393548308852,3.561469381603041,3.559005483711457,3.5565437874447383,3.5540842908356134,3.5516269919185754,3.549171888729865,3.5467189793074794,3.5442682616911734,3.5418197339224533,3.539373394044567,3.5369292401025225,3.5344872701430647,3.53204748221469,3.529609874367633,3.527174444653883,3.5247411911271507,3.522310111842902,3.519881204858335,3.517454468232382]},\"selected\":{\"id\":\"1048\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"1047\",\"type\":\"UnionRenderers\"}},\"id\":\"1036\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"1042\",\"type\":\"Title\"},{\"attributes\":{\"formatter\":{\"id\":\"1043\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"1002\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1012\",\"type\":\"BasicTicker\"}},\"id\":\"1011\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1017\",\"type\":\"BasicTicker\"}],\"root_ids\":[\"1002\"]},\"title\":\"Bokeh Application\",\"version\":\"1.0.0\"}};\n",
       "  var render_items = [{\"docid\":\"46d91368-31c8-4570-8911-3b52a4a7de5d\",\"roots\":{\"1002\":\"96abf8e5-1086-49b1-b0d0-3653c588e5e8\"}}];\n",
       "  root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
       "\n",
       "  }\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        embed_document(root);\n",
       "        clearInterval(timer);\n",
       "      }\n",
       "      attempts++;\n",
       "      if (attempts > 100) {\n",
       "        console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
       "        clearInterval(timer);\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "1002"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "result = []\n",
    "for e in range(epochs):\n",
    "    optim.zero_grad()\n",
    "    outputs = model(inputs)\n",
    "    loss = criterion(targets, outputs)\n",
    "    loss.backward()\n",
    "    optim.step()\n",
    "    result.append(float(loss))\n",
    "    \n",
    "fig = figure()\n",
    "fig.line(range(len(result)), result)\n",
    "show(fig)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Result\n",
    "检验预测结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-11-03T04:56:53.351604Z",
     "start_time": "2019-11-03T04:56:53.166138Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAELCAYAAADURYGZAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAH+tJREFUeJzt3Xl8VOW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CTmFAQiIjGnIBARibn/A6iuMjF9MuyQAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "preds = model(inputs).data.numpy()\n",
    "plt.figure() \n",
    "plt.scatter(x_train, y_train)\n",
    "plt.plot(x_train, preds)\n",
    "plt.xlabel('x_train')\n",
    "plt.ylabel('preds')\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "oldHeight": 511.99678000000006,
   "position": {
    "height": "40px",
    "left": "592.875px",
    "right": "20px",
    "top": "141.993px",
    "width": "760.538px"
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "varInspector_section_display": "none",
   "window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
